﻿<?php
import('Database.Dal.~');

/**
 * IndexController
 *
 * @package
 * @author darche
 * @copyright Copyright (c) 2009
 * @version $Id$
 * @access public
 */
class ContactController extends Hoa_Controller_Action_Standard {

	private $formContact;
	private $dataContact = array();

	/**
	 * IndexController::IndexAction()
	 *
	 * @return
	 */
	public function IndexAction(){
		$this->formContact = new FormContact();
		$this->view->form = $this->formContact;
		$this->view->config = $this->config;
		$this->view->titre = 'Contact';

		/**
		 * On fait la vérification des données.
		 */
		if($this->formContact->isValid()) {
			self::valideForm();
		}
		$this->view->head 	= $this->head;
		$this->view->config = $this->config;
		echo $this->view->render();
	}

	private function valideForm(){
		$this->dataContact = $_POST;
		print_r($this->dataContact);
		self::registerEmailIntoBDD();
	}

	private function registerEmailIntoBDD(){
		$data = array();
		$data['nom'] = $this->dataContact['nom'];

		$dataModeleTable = new Hoa_Database_QueryBuilder_Table();
		$dataModeleTable->insert($data);

		echo $dataModeleTable->getQuery();
	}

	private function sendEmailToDestinataire(){

	}

	private function sendEmailToEmetteur(){

	}

}